package io.renren.modules.app.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.modules.app.annotation.Login;
import io.renren.modules.app.annotation.LoginUser;
import io.renren.modules.app.entity.ImMomentCommentEntity;
import io.renren.modules.app.entity.ImReportEntity;
import io.renren.modules.app.entity.UserEntity;
import io.renren.modules.app.service.ImReportService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 *
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-05-26 10:26:38
 */
@RestController
@RequestMapping("app/imreport")
public class ImReportController {
    @Autowired
    private ImReportService imReportService;


    /**
     * 举报保存
     * @param user
     * @param imReport
     * @return
     */

    @Login
    @RequestMapping("/saveOne")
    //@RequiresPermissions("generator:imgroup:list")
    public R saveOne(@LoginUser UserEntity user , @RequestBody ImReportEntity imReport){

        R r = imReportService.saveOne(user,imReport);
        return r;
    }


    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:imreport:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = imReportService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:imreport:info")
    public R info(@PathVariable("id") Integer id){
		ImReportEntity imReport = imReportService.getById(id);

        return R.ok().put("imReport", imReport);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:imreport:save")
    public R save(@RequestBody ImReportEntity imReport){
		imReportService.save(imReport);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:imreport:update")
    public R update(@RequestBody ImReportEntity imReport){
		imReportService.updateById(imReport);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:imreport:delete")
    public R delete(@RequestBody Integer[] ids){
		imReportService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
